use axum::extract::Path;

use core::prelude::{ApiResponse, BizError};

use crate::domain::view::UserDetailVO;
use crate::service::UserService;

#[utoipa::path(
        get,
        path = "/users/{user_id}",
        tag = "User",
        operation_id = "user_get_user_detail",
        params(("user_id" = u64, Path, description = "user id")),
        responses(
            (status = 200, description = "get user detail info successfully", body = [ApiResponse<UserDetailVO>]),
            (status = 404, description = "not found user by id", body = BizError)
        )
    )]
pub async fn user_detail(Path(user_id): Path<u64>) -> ApiResponse<UserDetailVO> {
    let res = UserService::get_by_id(user_id).map(|user| user.into());
    res.into()
}
